$(function(){
	var basePath=$("#basepath").val();
	$("#chooseSetFilter_go").click(function(){
		var clgId=$("#chooseSetFilter_form select[name='college']").val();
		if(clgId==0){
			return;
		}
		window.location=basePath+"admin/choose/set/"+clgId;
	});
    $('.form_datetime').datetimepicker({
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		forceParse: 0,
        showMeridian: 1,
    });
    $("#choose_set_update_form_save").click(function(){
    	var clgId=$("#choose_set_update_form input[name=collegeId]").val();
    	var studentChooseTimeStart=$("#choose_set_update_form input[name=studentChooseTimeStart]").val()+":00";
    	var studentChooseTimeEnd=$("#choose_set_update_form input[name=studentChooseTimeEnd]").val()+":00";
    	var teacherEditTimeStart=$("#choose_set_update_form input[name=teacherEditTimeStart]").val()+":00";
    	var teacherEditTimeEnd=$("#choose_set_update_form input[name=teacherEditTimeEnd]").val()+":00";
    	var teacherUploadTimeStart=$("#choose_set_update_form input[name=teacherUploadTimeStart]").val()+":00";
    	var teacherUploadTimeEnd=$("#choose_set_update_form input[name=teacherUploadTimeEnd]").val()+":00";
    	var teacherChooseTimeStart=$("#choose_set_update_form input[name=teacherChooseTimeStart]").val()+":00";
    	var teacherChooseEachTimeLength=$("#choose_set_update_form select[name=teacherChooseEachTimeLength]").val();
    	var middleCheckTimeStart=$("#choose_set_update_form input[name=middleCheckTimeStart]").val()+":00";
    	var middleCheckTimeEnd=$("#choose_set_update_form input[name=middleCheckTimeEnd]").val()+":00";
    	var finalCheckTimeStart=$("#choose_set_update_form input[name=finalCheckTimeStart]").val()+":00";
    	var finalCheckTimeEnd=$("#choose_set_update_form input[name=finalCheckTimeEnd]").val()+":00";
    	var totalLevelCount=$("#choose_set_update_form select[name=totalLevelCount]").val();
    	var chooseByProject=$("#choose_set_update_form select[name=chooseByProject]").val();
    	$.post(basePath+ "admin/choose/updateChooseSet",
				{
    				'clgId':clgId,
    				'studentChooseTimeStart':studentChooseTimeStart,
    				'studentChooseTimeEnd':studentChooseTimeEnd,
    				'teacherEditTimeStart':teacherEditTimeStart,
    				'teacherEditTimeEnd':teacherEditTimeEnd,
    				'teacherUploadTimeStart':teacherUploadTimeStart,
    				'teacherUploadTimeEnd':teacherUploadTimeEnd,
    				'teacherChooseTimeStart':teacherChooseTimeStart,
    				'teacherChooseEachTimeLength':teacherChooseEachTimeLength,
    				'middleCheckTimeStart':middleCheckTimeStart,
    				'middleCheckTimeEnd':middleCheckTimeEnd,
    				'finalCheckTimeStart':finalCheckTimeStart,
    				'finalCheckTimeEnd':finalCheckTimeEnd,
    				'totalLevelCount':totalLevelCount,
    				'chooseByProject':chooseByProject
    			},
				function(data,textStatus){
					if(textStatus=="success"){
						switch (parseInt(data)) {
						case -1:
							alert("请勿进行非法操作");
							window.location=basePath;
							break;
						case -2:
							alert("所有选项均为必填项,请检查");
							break;
						case -3:
							alert("学生选题终止时间应晚于开始时间");
							break;
						case -4:
							alert("教师提交终止时间应晚于开始时间");
							break;
						case -5:
							alert("附件提交终止时间应晚于开始时间");
							break;
						case -6:
							alert("中期检查结束时间应晚于开始时间");
							break;
						case -7:
							alert("最终答辩结束时间应晚于开始时间");
							break;
						case -8:
							alert("志愿录取时间应在学生选题结束之后");
							break;
						case -9:
							alert("最终答辩应在中期检查结束之后");
							break;
						case -10:
							alert("其他错误");
							break;
						case 0:
							noty({text:"修改成功,正在刷新"});
							history.go(0);
							break;
						default:
							alert("登陆状态已过期,请重试");
							window.location=basePath;
						}
					}
				},"text");
    });
});